package com.gzck.gzck_verson2.controller;


import com.gzck.gzck_verson2.pojo.GSensorMeasurementType;
import com.gzck.gzck_verson2.service.IGSensorMeasurementTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 传感器测值类型表（前端展示用） 前端控制器
 * </p>
 *
 * @author 任永辉
 * @since 2024-01-27
 */
@RestController
@RequestMapping("/g-sensor-measurement-type")
public class GSensorMeasurementTypeController {

    @Autowired
    private IGSensorMeasurementTypeService sensorMeasurementTypeService;

    // 添加传感器测量类型信息
    @PostMapping("/add")
    public boolean addSensorMeasurementType(@RequestBody GSensorMeasurementType sensorMeasurementType) {
        return sensorMeasurementTypeService.save(sensorMeasurementType);
    }

    // 删除传感器测量类型信息
    @DeleteMapping("/delete/{id}")
    public boolean deleteSensorMeasurementType(@PathVariable Long id) {
        return sensorMeasurementTypeService.removeById(id);
    }

    // 更新传感器测量类型信息
    @PutMapping("/update")
    public boolean updateSensorMeasurementType(@RequestBody GSensorMeasurementType sensorMeasurementType) {
        return sensorMeasurementTypeService.updateById(sensorMeasurementType);
    }

    // 查询单个传感器测量类型信息
    @GetMapping("/{id}")
    public GSensorMeasurementType getSensorMeasurementType(@PathVariable Long id) {
        return sensorMeasurementTypeService.getById(id);
    }

    // 查询所有传感器测量类型信息
    @GetMapping("/all")
    public List<GSensorMeasurementType> getAllSensorMeasurementTypes() {
        return sensorMeasurementTypeService.list();
    }
}
